<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta charset="utf-8">
	<title></title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<meta name="author" content="">
	<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
	<link href="css/daterangepicker.min.css" rel="stylesheet">
	<link rel="stylesheet" href="css/main.css">
	<style rel="stylesheet" type="text/css">
		.no-info{
			padding-top: 20px;
			padding-bottom: 20px;
			text-align: center;
		}
	</style>
	<!--[if lt IE 9]>
	<script src="js/html5shiv.min.js"></script>
	<script src="js/respond.min.js"></script>
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>
	<![endif]-->
<meta name="renderer" content="webkit">
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div id="apps">
	<header id="header"></header>
	<div class="header-space"></div>

	<section class="g-main">
		<div class="content">
			<div class="main-left">

				<div class="js_slideTxtBox g-slideTxtBoxLine">
					<div class="hd">
						<ul>
							<li :class="bug === 1 ? 'on' : ''" @click="goBut(1, 'activityList')">我的活动</li>
							<li :class="bug === 2 ? 'on' : ''" @click="goBut(2, 'footprintList')">
								<div class="select-box">
									<span class="arrow">我的足迹</span>
									<div class="select-con">
										<a style="cursor: pointer;" @click="bugOutFun(0)">招聘</a>
										<a style="cursor: pointer;" @click="bugOutFun(1)">企业</a>
									</div>
								</div>
							</li>
							<li :class="bug === 3 ? 'on' : ''" @click="goBut(3, 'keepList')">我的收藏</li>
						</ul>
					</div>
					<div class="bd">
						<!-- 我的活动 -->
						<div class="con con1" v-if="bug === 1">
							<section class="section181">

								<div class="list">
									<div class="no-info" v-if="!activityList || activityList.length === 0">暂无数据</div>
									<div class="item" v-for="(list, index) in activityList || []" :key="'hd' + index">
										<div class="img"><a :href="'19.html?id=' + list.activity_id"><img :src="list.activity.cover ? list.activity.cover : 'images/img181.png'" alt=""></a></div>
										<div class="right">
											<div class="title"><a :href="'19.html?id=' + list.activity_id">{{list.activity.name}}</a></div>
											<div class="txt">报名时间：{{list.created_at}}</div>
										</div>
									</div>
								</div>



								<div class="g-prvNxt">
									<a style="cursor: pointer;" @click="pageJumpFun('min', 'activity', getActivity)" class="prev">&nbsp;</a>
									<a style="cursor: pointer;" :class="activityPage == list ? 'on' : ''" v-for="list in Math.ceil(activityTotal / activityNum)" :key="list" @click="pageJumpFun(list, 'activity', getActivity)">{{list}}</a>
									<a style="cursor: pointer;" class="next" @click="pageJumpFun('max', 'activity', getActivity)">&nbsp;</a>
									<select v-model="activityNum">
										<option value="15">15条/页</option>
										<option value="20">20条/页</option>
										<option value="30">30条/页</option>
										<option value="40">40条/页</option>
										<option value="50">50条/页</option>
									</select>
									跳至
									<input type="text" v-model="activityPages" class="input">
									页
									<input type="submit" value="确定" class="btn" @click="pageJumpFun(activityPages, 'activity', getActivity)">
								</div>

							</section>
						</div>
						<!-- /我的活动 -->
						<!-- 我的足迹 -->
						<div class="con con2" v-if="bug === 2">
							<!-- 企业 -->
							<section class="section182" v-if="bugOut === 1">
								<div class="list">
									<template v-for="list in footprintList">
										<div class="date">{{list.time}} <i class="line"></i></div>
										<div class="item" v-for="(item, index) in list.date || []" :key="'qy' + list.time + index">
											<div class="checkbox" :class="item.checkbox ? 'on' : ''" @click="checkboxFun(item, 'footprint')"></div>
											<div class="face"><a :href="'08.html?id=' + item.id"><img :src="item.logo ? item.logo : 'images/face.jpg'" alt=""></a></div>
											<div class="con">
												<h3><a :href="'08.html?id=' + item.id"><b>{{item.name}}</b></a></h3>
												<p>{{addressSearch(paramList.region, item.area_id)}}&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.type, item.type_id, 'id', 'name')}}</p>
												<p><time>{{timeFun(list.created_at)}}</time></p>
											</div>
											<a :href="'08.html?id=' + item.id" class="btn">查看招聘信息</a>
										</div>
									</template>
									<div class="no-info" v-if="!footprintList || footprintList.length === 0">暂无数据</div>
								</div>

								<div class="operate-box">
									<div class="checkboxAll" :class="footprintCheckbox ? 'on' : ''" @click="checkFun(footprintCheckbox, 'footprint')">全选</div>
									<a style="cursor: pointer;" @click="delFun('footprintList')" class="btn">删除</a>
								</div>

								<div class="g-prvNxt">
									<a style="cursor: pointer;" @click="pageJumpFun('min', 'footprint', getFootprint)" class="prev">&nbsp;</a>
									<a style="cursor: pointer;" :class="footprintPage == list ? 'on' : ''" v-for="list in Math.ceil(footprintTotal / footprintNum)" :key="'zj'+list" @click="pageJumpFun(list, 'footprint', getFootprint)">{{list}}</a>
									<a style="cursor: pointer;" class="next" @click="pageJumpFun('max', 'footprint', getFootprint)">&nbsp;</a>
									<select v-model="footprintNum">
										<option value="15">15条/页</option>
										<option value="20">20条/页</option>
										<option value="30">30条/页</option>
										<option value="40">40条/页</option>
										<option value="50">50条/页</option>
									</select>
									跳至
									<input type="text" v-model="footprintPages" class="input">
									页
									<input type="submit" value="确定" @click="pageJumpFun(footprintPages, 'footprint', getFootprint)" class="btn">
								</div>

							</section>




							<!-- 招聘 -->
							<section class="section183" v-if="bugOut === 0">
								<div class="list">
									<template v-for="list in footprintList">
										<div class="date">{{list.time}} <i class="line"></i></div>
										<div class="item" class="item" v-for="(item, index) in list.date || []">
											<div class="checkbox" :class="item.checkbox ? 'on' : ''" @click="checkboxFun(item, 'footprint')"></div>
											<div class="con">
												<h3><a :href="'07.html?id=' + item.id"><b>{{item.name}}</b></a> <span class="orange e2">{{item.salary_min}}-{{item.salary_max}}K</span></h3>
												<p>{{matchFun(paramList.education, item.education_id, 'id', 'name')}}及以上&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.experience, item.experience_config_id, 'id', 'min') + '-' + matchFun(paramList.experience, item.experience_config_id, 'id', 'max')}}年</p>
												<p>
													<span class="tag" v-for="(items, index) in item.recruit_welfare || []">{{matchFun(paramList.tag, items.welfare_id, 'id', 'name')}}</span>
												</p>
											</div>
											<div class="con">
												<h3><a :href="'08.html?id=' + item.enterprise_id">{{item.enterprise.name}}</a></h3>
												<p>{{addressSearch(paramList.region, item.area_id)}}&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.type, item.enterprise.type_id, 'id', 'name')}}</p>
												<p><time>{{timeFun(item.updated_at)}}</time></p>
											</div>

										</div>
									</template>
									<div class="no-info" v-if="!footprintList || footprintList.length === 0">暂无数据</div>

								</div>

								<div class="operate-box">
									<div class="checkboxAll" :class="footprintCheckbox ? 'on' : ''" @click="checkFun(footprintCheckbox, 'footprint')">全选</div>
									<a style="cursor: pointer;" @click="delFun('footprintList')" class="btn">删除</a>
								</div>

								<div class="g-prvNxt">
									<a style="cursor: pointer;" @click="pageJumpFun('min', 'footprint', getFootprint)" class="prev">&nbsp;</a>
									<a style="cursor: pointer;" :class="footprintPage == list ? 'on' : ''" v-for="list in Math.ceil(footprintTotal / footprintNum)" :key="'zplb'+list" @click="pageJumpFun(list, 'footprint', getFootprint)">{{list}}</a>
									<a style="cursor: pointer;" class="next" @click="pageJumpFun('max', 'footprint', getFootprint)">&nbsp;</a>
									<select v-model="footprintNum">
										<option value="15">15条/页</option>
										<option value="20">20条/页</option>
										<option value="30">30条/页</option>
										<option value="40">40条/页</option>
										<option value="50">50条/页</option>
									</select>
									跳至
									<input type="text" v-model="footprintPages" class="input">
									页
									<input type="submit" value="确定" @click="pageJumpFun(footprintPages, 'footprint', getFootprint)" class="btn">
								</div>

							</section>


						</div>
						<!-- /我的足迹 -->
						<!-- 我的收藏 -->
						<div class="con con3" v-if="bug === 3">

							<section class="section183">
								<div class="list">

									<template v-for="(list, index) in keepList">
										<div class="date">{{list.time}} <i class="line"></i></div>
										<div class="item" v-for="item in list.date" :key="'sc'+item.id">
											<div class="checkbox" :class="item.checkbox ? 'on' : ''" @click="checkboxFun(item, 'keep')"></div>
											<div class="con">
												<h3><a :href="'07.html?id=' + item.id"><b>{{item.name}}</b></a> <span class="orange e2">{{item.salary_min}}-{{item.salary_max}}K</span></h3>
												<p>{{matchFun(paramList.education, item.education_id, 'id', 'name')}}及以上&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.nature, item.type, 'id', 'name')}}&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.experience, item.experience_config_id, 'id', 'min') + '-' + matchFun(paramList.experience, item.experience_config_id, 'id', 'max')}}年</p>
												<p>
													<span class="tag" v-for="(items, index) in item.recruit_welfare || []">{{matchFun(paramList.tag, items.welfare_id, 'id', 'name')}}</span>
												</p>
											</div>
											<div class="con">
												<h3><a :href="'08.html?id=' + item.enterprise_id">{{item.enterprise.name}}</a></h3>
												<p>{{addressSearch(paramList.region, item.area_id)}}&nbsp;&nbsp;|&nbsp;&nbsp;{{matchFun(paramList.type, item.enterprise.type_id, 'id', 'name')}}</p>
												<p><time>{{timeFun(item.updated_at)}}</time></p>
											</div>
										</div>
									</template>

									<div style="text-align: center;padding: 40px 0;" v-if="keepList.length === 0">暂无数据</div>
								</div>

								<div class="operate-box">
									<div class="checkboxAll" :class="keepCheckbox ? 'on' : ''" @click="checkFun(keepCheckbox, 'keep')">全选</div>
									<a style="cursor: pointer;" @click="delFun('keepList', 'collect_id')" class="btn">删除</a>
								</div>

								<div class="g-prvNxt">
									<a style="cursor: pointer;" @click="pageJumpFun('min', 'keep', getKeep)" class="prev">&nbsp;</a>
									<a style="cursor: pointer;" :class="keepPage == list ? 'on' : ''" v-for="list in Math.ceil(keepTotal / keepNum)" :key="'sclb'+list" @click="pageJumpFun(list, 'keep', getKeep)">{{list}}</a>
									<a style="cursor: pointer;" class="next" @click="pageJumpFun('max', 'keep', getKeep)">&nbsp;</a>
									<select v-model="keepNum">
										<option value="15">15条/页</option>
										<option value="20">20条/页</option>
										<option value="30">30条/页</option>
										<option value="40">40条/页</option>
										<option value="50">50条/页</option>
									</select>
									跳至
									<input type="text" v-model="keepPages" class="input">
									页
									<input type="submit" value="确定" @click="pageJumpFun(keepPages, 'keep', getKeep)" class="btn">
								</div>



							</section>
						</div>
						<!-- /我的收藏 -->
					</div>
				</div>


			</div>
			<div class="main-right">


				<div class="g-user">
					<a href="21.html" class="btn-edit">编辑</a>
					<img :src="userInfo.image ? userInfo.image : 'images/noUser.png'" alt="" class="face">
					<h3>{{userInfo.name || 'images/noUser.png'}}</h3>
					<div class="txt">{{userInfo.experience}}</div>
					<div class="info">
						<div class="item">
							<h4>{{userInfo.invite}}</h4>
							<p>面试邀请</p>
						</div>
						<div class="item">
							<h4>{{userInfo.watch}}</h4>
							<p>被查看</p>
						</div>
						<div class="item">
							<h4>{{userInfo.out}}</h4>
							<p>不合适</p>
						</div>
						<div class="item">
							<h4>{{userInfo.send}}</h4>
							<p>已投递</p>
						</div>
					</div>
				</div>
				<div class="g-sideInfo">
					<h3>简历类型</h3>
					<div class="hd">
						<a style="cursor: pointer;" :class="userInfo.type && userInfo.type.language === 0 ? 'on' : ''" @click="userInfo.type.language = 0">中文版</a><a style="cursor: pointer;" :class="userInfo.type && userInfo.type.language === 1 ? 'on' : ''" @click="userInfo.type.language = 1">英文版</a>
					</div>
					<h3>隐私设置 <a style="cursor: pointer;" class="blue" @click="upHidde(userInfo.type.hidden === 0 ? 1 : 0)">{{userInfo.type && userInfo.type && userInfo.type.hidden === 0 ? '隐藏简历' : '显示简历'}}</a></h3>
					<div class="con">
						<div class="item" style="position:relative;">
							简历设置 <span style="position:absolute;right: 0;">{{userInfo.type && userInfo.type && userInfo.type.hidden === 0 ? '已显示' : '已隐藏'}}</span><!-- <text style="position:absolute;right: 0;">已隐藏</text>-->
						</div>
					</div>
				</div>


			</div>
		</div>
	</section>

	<footer>
		<div class="content">
			<div class="menu">
				<a href="20.html">联系我们</a>
				<a href="23.html">意见反馈</a>
				<a href="24.html">关于我们</a>
			</div>
			<div class="cpt">
				Copyright &#169 2019 人员招聘 ICP备14013400号-1京ICP证150920号 电子营业执照 <a href="">京公网安备11010502031234</a> 首都网警 <a href="">人力资源服务许可证</a>
			</div>
		</div>
	</footer>
</div>
<script src="js/lcommon.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/slide.min.js"></script>
<script src="js/polyfill.min.js"></script>
<script src="js/jquery.nicescroll3.7.6.min.js"></script>
<!--<script src="js/main.js"></script>-->

<script src="js/vue.js"></script>
<script src="js/request.js"></script>

<script>
	$(function () {
		$("#header").load("./lcommon/header.html");
	})
	var vm = new Vue({
		el:'#apps',
		data() {
			return {
				bug: 1,	// 1 我的活动 2 我的足迹 3 我的收藏
				bugOut: 0,	// 0 招聘 1 企业

				/** 活动 **/
				activityList: [],
				activityNum: 15,
				activityPage: 1,
				activityTotal: 0,
				activityPages: '',

				/** 足迹 **/
				footprintList: [],
				footprintNum: 15,
				footprintPage: 1,
				footprintTotal: 0,
				footprintPages: '',
				footprintCheckbox: false,

				/** 收藏 **/
				keepList: [],
				keepNum: 15,
				keepPage: 1,
				keepTotal: 0,
				keepPages: '',
				keepCheckbox: false,

				paramList: [],	// 查询到的列表数据
				userInfo: {}	// 个人数据

			}
		},
		created() {
			this.getUserInfo();
			this.getBasis();
			this.getActivity();
		},
		methods: {
			addressSearch(list, val) {
				for (let i = 0; i < list.length; i++) {
					if (Number(list[i].id) === Number(val)) {
						return list[i].region_name;
					} else if (list[i].children && list[i].children.length > 0) {
						let str = this.addressSearch(list[i].children, val);
						if (str) return list[i].region_name + '-' + str;
					}
				}
				return '';
			},
			checkFun(val, check) {
				let name = check + 'List';
				let nameCheck = check + 'Checkbox';
				this[nameCheck] = val ? false : true;
				this[name] = this.upCheck(this[name], this[nameCheck]);
			},
			upCheck(list, val) {
				for (let i = 0; i < list.length; i++) {
					if (list[i].date && list[i].date.length > 0) {
						for (let a = 0; a < list[i].date.length; a++) {
							list[i].date[a].checkbox = val;
						}
					}
				}
				return list;
			},
			checkboxFun(item, val) {
				item.checkbox = item.checkbox ? false : tradeList;
				let name = val + 'List';
				let nameCheck = val + 'Checkbox';
				let date = this[name];
				for (let i = 0; i < date.length; i++) {
					if (date[i].date && date[i].date.length > 0) {
						let item = date[i].date;
						for (let a = 0; a < item.length; a++) {
							if (!item[a].checkbox) {
								this[nameCheck] = false;
								return false;
							}
						}
					}
				}
				this[nameCheck] = true;
			},
			timeFun(val) {
				var timestamp = new Date(val).getTime();

				var minute = 1000 * 60;
				var hour = minute * 60;
				var day = hour * 24;
				var halfamonth = day * 15;
				var month = day * 30;
				var year = day * 365;
				var now = new Date().getTime();
				var diffValue = now - timestamp;
				var result;
				if (diffValue < 0) {
					return;
				}
				var yearC = diffValue / year;
				var monthC = diffValue / month;
				var weekC = diffValue / (7 * day);
				var dayC = diffValue / day;
				var hourC = diffValue / hour;
				var minC = diffValue / minute;
				if (yearC >= 1) {
					result = "" + parseInt(yearC) + "年前";
				} else if (monthC >= 1) {
					result = "" + parseInt(monthC) + "月前";
				} else if (weekC >= 1) {
					result = "" + parseInt(weekC) + "周前";
				} else if (dayC >= 1) {
					result = "" + parseInt(dayC) + "天前";
				} else if (hourC >= 1) {
					result = "" + parseInt(hourC) + "小时前";
				} else if (minC >= 1) {
					result = "" + parseInt(minC) + "分钟前";
				} else
					result = "刚刚";
				return result;
			},
			// 匹配方法 list 需要匹配的列表 val 匹配的值 item 匹配的字段
			matchFun(list, val, item, name) {
				for (let i = 0; i < list.length; i++) {
					if (item) {
						if (list[i][item] == val) {
							return list[i][name];
						}
					} else {}
				}
			},
			bugOutFun(val) {
				if (this.bugOut !== val) {
					this.bugOut = val;
					this.getFootprint();
				}
			},
			// 页数加减 or 跳页
			pageJumpFun(page, name, fun) {
				let strPage = name + 'Page';
				if (page === 'min') {
					if (this[strPage] !== 1) {
						this[strPage] -= 1;
						fun();
					}
				} else if (page === 'max') {
					let num = name + 'Num';
					let total = name + 'Total';
					if (this[strPage] * this[num] < this[total]) {
						this[strPage] += 1;
						fun();
					}
				} else {
					this[strPage] = page;
					fun();
				}
			},
			// 删除
			delFun(name, idName) {
				let arr = [];
				let date = this[name];
				for (let i = 0; i < date.length; i++) {
					if (date[i].date) {
						(date[i].date).map(val => {
							if (val.checkbox) {
								if (idName) {
									arr.push(val[idName]);
								} else {
									arr.push(val.id);
								}
							}
						})
					}
				}

				if (name === 'footprintList') {
					this.upDelFootpring(arr);
				}
				if (name === 'keepList') {
					this.upDelKeep(arr);
				}
			},
			upDelKeep (arr) {
				let url = 'person/my/collect';
				request(url, 'DELETE', JSON.stringify({id: arr}), res => {
					if (res.code === 1) {
						this.getKeep();
					}
				}, err => {
					console.log(err)
				})
			},
			upDelFootpring (arr) {
				let url = 'person/my/footmark';
				request(url, 'DELETE', JSON.stringify({id: arr}), res => {
					if (res.code === 1) {
						this.getFootprint();
					}
				}, err => {
					console.log(err)
				})
			},
			goBut(val, name) {
				this.bug = val;
				// 没有数据的一律走一次
				if (this[name] && this[name].length === 0) {
					if (name === 'footprintList') this.getFootprint();
					if (name === 'keepList') this.getKeep();
				}
			},
			getKeep() {
				let url = 'person/my/collect';
				request(url,'GET', {page: this.keepPage},(res)=>{
					if (res.code === 1) {
						this.keepTotal = res.data.total;
						let arr = [];
						for (let i in res.data.list) {
							console.log('便利', i)
							arr.push({
								time: i,
								date: (res.data.list[i]).map(val => {
									val.checkbox = false;
									return val;
								})
							})
						}
						this.keepList = arr;
						console.log('结果', this.keepList)
					}
				}, err => {
					console.log(err)
				})
			},
			upHidde(val) {
				let url = 'person/resume/hidden';
				request(url, 'PUT', JSON.stringify({hidden: val}), res => {
					if (res.code === 1) {
						this.userInfo.type.hidden = val;
					}
				}, err => {
					console.log(err)
				})
			},
			// 足迹
			getFootprint() {
				let url = 'person/my/footmark/' + this.bugOut;
				request(url,'GET', {type: this.bugOut, page: this.footprintPage},(res)=>{
					if (res.code === 1) {
						this.footprintTotal = res.data.total;
						let arr = [];
						for (let i in res.data.list) {
							console.log('便利', i)
							arr.push({
								time: i,
								date: (res.data.list[i]).map(val => {
									val.checkbox = false;
									return val;
								})
							})
						}
						this.footprintList = arr;
					}
				}, err => {
					console.log(err)
				})
			},
			// 我的活动列表
			getActivity() {
				let url = 'person/my/activity';
				request(url,'GET', {page: this.activityPage},(res)=>{
					if (res.code === 1) {
						this.activityTotal = res.data.total;
						this.activityList = res.data.activity;
					}
				}, err => {
					console.log(err)
				})
			},
			getUserInfo() {
				let url = 'person/my/info';
				request(url, 'GET', '', res => {
					console.log(res);
					if (res.code === 1) {
						this.userInfo = res.data.info;
					}
				}, error => {
					console.log('error')
				})
			},
			// 基础数据
			getBasis() {
				let url = 'person/my/prepare';
				request(url, 'GET', '', res => {
					if (res.code === 1) {
						this.paramList = res.data;
					}
				}, err => {
					console.log(err)
				})
			},
			getUserInfo() {
				if (!this.getToken()) return;
				let url = 'person/my/info';
				request(url, 'GET', '', res => {
					console.log(res);
					if (res.code === 1) {
						this.userInfo = res.data.info;
					}
				}, error => {
					console.log('error')
				})
			},
			getToken() {
				return sessionStorage.getItem("token") || null;
			}
	}
	})
</script>
</body>
</html>